<template>
	<view>
		<view class="header">
			<image src="../../static/uview/example/js_bak.png" ></u-image>
			<view class="user_item_id " style="margin-left: 40rpx;" @click="hanleUserInfo">
				<span>
					用户ID:{{user.userId}}
				</span>
				<span style="margin-left: 200rpx;color: #2979FF;">></span>
				</view>
		</view>
		<view>
			<uni-card @click="show1=true">关于</uni-card>
			<u-popup :show="show1" mode="center"   @close="show1=false">
			      <view>
			                  <view>江苏师范大学信息门户 v1.0</view>
							  <text>@Author 杨轶博</text>
			              </view>
				</u-popup>
			<uni-card  @click="show2=true">帮助</uni-card>
			<u-popup :show="show2" mode="center"  @close="show2=false" >
			        <view>
			            <text>如遇到系统错误,请联系xxxxxx@qq.com邮箱</text>
			        </view>
				</u-popup>
			<uni-card @click="goHome()">退出</uni-card>
		</view>

	</view>
</template>

<script>
	import {mapActions} from 'vuex'
	export default {
		data() {
			return {
				user:'',
				show1:false,
				show2:false,
				userId:''
			}
		},
		onShow() {
			this.initData()
		},
		methods: {
			...mapActions([
			                'Logout'
			            ]),
			goHome(){
				this.Logout().then(()=>{
					uni.reLaunch({
						url:"../login/login"
					})
					location.reload()
				})
			},
			hanleUserInfo(){
				uni.navigateTo({
					url:"../admin_user_info/admin_user_info"
				})
			},
			initData(){
				uni.request({
					url:'/api/user/getUserInfo',
					method:'get',
					header:{
						'Authorization':this.$store.getters.token
					},
					success: (res) => {
						if(res.data.code===200){
							this.user = res.data.data
							if( res.data.data.role === 1){
								this.user.role = '教师'
							}else if(res.data.data.role === 3){
								this.user.role = '教务老师'
							}else{
								this.user.role = '管理员'
							}
						}else{
							uni.showToast({
								icon:'error',
								position:'bottom',
								title:'查询失败'
							})
						}
					},})
					
					
			}
		}
	}
</script>

<style>
.header{
	background-color: #416262;
	margin: 10rpx;
	height: 200rpx;
	border-radius: 10rpx;
	display: flex;
	flex-direction: row;
	align-items: center;
}
.user_item_id{
	font-size: 30rpx;
}
.header image{
	width: 70rpx;
	height: 70rpx;
	margin-left: 40rpx;
}
.iamge{
	margin-left: 100rpx;
}

.user{
	border-radius: 10rpx;
	margin: 10rpx;
	display: flex;
	flex-direction: column;
	background-color: #aaffff;
}
.user_item{
	margin: 20px;
}
</style>
